projects
/
emacs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c3b4485
)
Optimise (cons X nil) to (list X)
author
Mattias Engdegård
<mattiase@acm.org>
Thu, 3 Jun 2021 19:15:11 +0000
(21:15 +0200)
committer
Mattias Engdegård
<mattiase@acm.org>
Thu, 3 Jun 2021 19:28:10 +0000
(21:28 +0200)
* lisp/emacs-lisp/byte-opt.el (byte-optimize-cons): New function.
lisp/emacs-lisp/byte-opt.el
patch
|
blob
|
history
diff --git
a/lisp/emacs-lisp/byte-opt.el
b/lisp/emacs-lisp/byte-opt.el
index 10a50da46288203ececaa96343d5bab146fc7fc4..99e84e23ad8c5a4edc437bdb37097be0a978588f 100644
(file)
--- a/
lisp/emacs-lisp/byte-opt.el
+++ b/
lisp/emacs-lisp/byte-opt.el
@@
-1269,6
+1269,14
@@
See Info node `(elisp) Integer Basics'."
form)
form))
+(put 'cons 'byte-optimizer #'byte-optimize-cons)
+(defun byte-optimize-cons (form)
+ ;; (cons X nil) => (list X)
+ (if (and (= (safe-length form) 3)
+ (null (nth 2 form)))
+ `(list ,(nth 1 form))
+ form))
+
;; Fixme: delete-char -> delete-region (byte-coded)
;; optimize string-as-unibyte, string-as-multibyte, string-make-unibyte,
;; string-make-multibyte for constant args.